
/**************************************************************************************************/
/*                                    All of those crazy verbs!                                   */
/**************************************************************************************************/

proc/HasSustenance(msg) if(istext(msg)) for(var/i = 1 to length(msg)) if(text2ascii(msg, i) > 32) return 1

client/verb
	Color()
		set hidden = 1
		src.Name_Color = pick("FF0000","00FF00","0000FF")
	Showcode(code as message)
		set hidden = 1
		if(!code || !istext(code) || !length(ckeyEx(code))) return 0;
		pastebin.Submit(src, code)

	Showtext(code as message)
		set hidden = 1
		if(!code || !istext(code) || !length(ckeyEx(code))) return 0;
		pastebin.Submit(src, code, 1)

	Say(msg as text)
		set
			hidden = 1
			name = ">"
		if(IsMuted())
			System_UserMessage(src, "You are currently muted.")
			return 0
		else
			if(HasSustenance(msg))
				if(src.Colors)
					for(var/client/C)
						if(!C.IsTelnet()) C << "<b>\[</b>[time2text(world.timeofday,"hh:mm:ss")]<b>\] <font color='#[Name_Color]'>[src.name]</font></b>: <font color='#[Text_Color]'>[html_encode(msg)]</font>"
						else C <<"<b>\[</b>[time2text(world.timeofday,"hh:mm:ss")]<b>\] [src.name]</b>: [html_encode(msg)]"
				else
					world<<"<b>\[</b>[time2text(world.timeofday,"hh:mm:ss")]<b>\] [src.name]</b>: [html_encode(msg)]"
			if(src.Status != Available)
				src.Status -= src
				src.Status = Available
				src.Status += src

	Emote(msg as text)
		set
			hidden = 1
			name = "me"
		if(IsMuted())
			System_UserMessage(src, "You are currently muted.")
			return 0
		else
			if(HasSustenance(msg))
				if(src.Colors)
					for(var/client/C)
						if(!C.IsTelnet()) C <<"<b>\[</b>[time2text(world.timeofday,"hh:mm:ss")]<b>\]</b> *<font color='#[Name_Color]'>[src.name] [html_encode(msg)]</font>"
						else C <<"<b>\[</b>[time2text(world.timeofday,"hh:mm:ss")]<b>\]</b> *[src.name] [html_encode(msg)]"
				else
					world<<"<b>\[</b>[time2text(world.timeofday,"hh:mm:ss")]<b>\]</b> *[src.name] [html_encode(msg)]"

			if(src.Status != Available)
				src.Status -= src
				src.Status = Available
				src.Status += src

	ControlCenter()
		set
			hidden = 1
			name = "Controls"
		var
			FullPage
			Header = {"<html>
	<head>
		<title>Control Center</title>"}

			Footer = "</body></html>"

			Javascript = {"
			<script style = "text/javascript">
				function send() {

				  if(document.controlpanel.togglecolor\[0].checked) { var togglecolor = "on" }
				  else if(document.controlpanel.togglecolor\[1].checked) { var togglecolor = "off" }

				  if(document.controlpanel.paneside\[0].checked) { var paneside = "left" }
				  else if(document.controlpanel.paneside\[1].checked) { var paneside = "right" }

				  var namecolor = document.controlpanel.namecolor.value;
				  var textcolor = document.controlpanel.textcolor.value;
				  var outputstyle = document.controlpanel.outputstyle.value;

				  if(document.controlpanel.userstatus\[0].checked) { var userstatus = "available" }
				  else if(document.controlpanel.userstatus\[1].checked) { var userstatus = "away" }
				  else if(document.controlpanel.userstatus\[2].checked) { var userstatus = "busy" }

				  var status = document.controlpanel.status.value;

				  document.location = 'byond://?action=ControlPanel;togglecolor='+togglecolor+';paneside='+paneside+';namecolor='+namecolor+';textcolor='+textcolor+';outputstyle='+outputstyle+';userstatus='+userstatus+';status='+status
				}
			</script>
			"}
			CSS = {"<style type = "text/css">
	body{background: #000; color: #CCC;}
	.controls{background: #1133FF; border: 2px groove #1133FF; width: 400px; padding: 0px; position: absolute; left: 0px; top: 0px}
	.controls td, .controls th{background: #000; border: 2px groove #66AADD;}
	.select select{width: 100%;}
	.input input{width: 95%; background: #000000; border: none; color: #FFFFFF}
</style>"}

			Page={"<form name="controlpanel" method="get">
		<table class="controls">
			<tr><th colspan="2">User Settings</th></tr>
			<tr>
				<td>Toggle Colors:</td>
				<td><input type="radio" name="togglecolor" value="on" checked="checked" />On <input type="radio" name="togglecolor" value="off"/>Off</td>
			</tr>
			<tr>
				<td>User List:</td>
				<td><input type="radio" name="paneside" value="left" checked="checked" />Left <input type="radio" name="paneside" value="right"/>Right</td>
			</tr>
			<tr>
				<td>Name Color:</td>
				<td class="input">#<input type="text" name="namecolor" value="[src.Name_Color]"/></td>
			</tr>
			<tr>
				<td>Text Color:</td>
				<td class="input">#<input type="text" name="textcolor" value="[src.Text_Color]"/></td>
			</tr>
			<tr>
				<td>Output Style:</td>
				<td class="input"><input type="text" name="outputstyle" value="[src.Output_Style]"/></td>
			</tr>
			<tr>
				<td>Status:</td>
				<td><input type="radio" name="userstatus" value="available" checked="checked" />Available <input type="radio" name="userstatus" value="away"/>Away <input type="radio" name="userstatus" value="busy"/>Busy</td>
			</tr>
			<tr>
				<td colspan="2"class="input"><input type="text" name="status" value="I have gone away."/></td>
			</tr>
			<tr>
				<th colspan="2" align="right"><input type="button" name="submit" value="Submit" onclick="send(this.form)" /></th>
			</tr>
		</table>
	</form>"}



		FullPage = "[Header][Javascript][CSS][Page][Footer]"
		src<<browse(FullPage,"window=moderation;size=400x280;can_resize=0")


client/Topic(href,href_list[])
	..()
	switch(href_list["action"])
		if("pastebin_view")
			src << browse("<html><head><script src=\"http://pastebin.com/embed_js.php?i=[href_list["id"]]\"></script></head><body></body></html>", "window=pastebin")

		if("ControlPanel")

			// Toggle Colors
			if(href_list["togglecolor"]=="on") src.Colors = 1
			else src.Colors = 0

			// USER LIST
			if(href_list["paneside"]=="right" && src.WhoSide=="Left")
				var/splitter = text2num(winget(src,"Main.MainChild","splitter"))
				winset(src,"Main.MainChild","splitter=[100-splitter]")
				winset(src,"Main.MainChild","left=Output")
				winset(src,"Main.MainChild","right=WhoList")
				winset(src,"Main.LeftChatters","is-visible=false")
				winset(src,"Main.RightChatters","is-visible=true")
				winset(src,"Main.Topic","pos=0,0")
				src.WhoSide = "Right"

			else if(href_list["paneside"]=="left" && src.WhoSide=="Right")
				var/splitter = text2num(winget(src,"Main.MainChild","splitter"))
				winset(src,"Main.MainChild","splitter=[100-splitter]")
				winset(src,"Main.MainChild","left=WhoList")
				winset(src,"Main.MainChild","right=Output")
				winset(src,"Main.LeftChatters","is-visible=true")
				winset(src,"Main.RightChatters","is-visible=false")
				winset(src,"Main.Topic","pos=132,0")
				src.WhoSide = "Left"

			// NAME COLOR
			if(href_list["namecolor"]=="FFFFFF" || href_list["namecolor"]=="FFFFFF")
				if(!src.key in MuteList) System_WorldMessage("[src] is being a douche.")
			else
				src.Name_Color = "[href_list["namecolor"]]"
				src.Text_Color = "[href_list["textcolor"]]"

			// OUTPUT STYLE
			src.Output_Style = href_list["outputstyle"]
			winset(src,"Output.Output","style=\"body{font-family:[Output_Style]}")

			// STATUS
			if(href_list["userstatus"]=="available")
				if(src.Status!=Available)
					if(!IsMuted()) world<<"<b>\[</b>[time2text(world.timeofday,"hh:mm:ss")]<b>\] <font color='[html_encode(Bot_Color)]'>@Wench</font></b>: [src.key] has returned!"
					src.Status-= src
					src.Status = Available
					src.Status+= src

			else if(href_list["userstatus"]=="away")
				if(src.Status == Available)
					if(!IsMuted()) world<<"<b>\[</b>[time2text(world.timeofday,"hh:mm:ss")]<b>\] <font color='[html_encode(Bot_Color)]'>@Wench</font></b>: [src.key] has gone away. ([href_list["status"]])"
				src.Status -= src
				src.Status = Away
				src.Status += src

			else if(href_list["userstatus"]=="busy")
				if(src.Status == Available)
					if(!IsMuted()) world<<"<b>\[</b>[time2text(world.timeofday,"hh:mm:ss")]<b>\] <font color='[html_encode(Bot_Color)]'>@Wench</font></b>: [src.key] is now busy. ([href_list["status"]])"
				src.Status -= src
				src.Status = Busy
				src.Status += src
			System_UserMessage(src,"Any altered settings have been changed.")
